package com.earthea.application.utils;

import com.earthea.common.constant.BaseConstants;
import com.earthea.common.constant.LogConstants;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

public class BaseLogUtils {
    private static final Logger JOB_LOG = LoggerFactory.getLogger("jobLog");

    public static void printJobLog(String jobName, String result, Map<String, String> logParams) {
        StringBuilder builder = new StringBuilder();
        builder.append(BaseConstants.PIPE).append(Thread.currentThread().getName()).append(BaseConstants.PIPE).append(jobName).append(BaseConstants.PIPE).append(logParams).append(BaseConstants.PIPE).append(result);
        if (StringUtils.equals(result, LogConstants.FAIL)) {
            JOB_LOG.error(builder.toString());
        } else {
            JOB_LOG.info(builder.toString());
        }
    }

}
